<?php

    function mydate($date)
    {
       $day=substr($date,8,2);
       //$mymonth = array('January','February','March','April','May','June','July','August','September','October','November','December');
       $mymonth = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
       $month=substr($date,5,2);
       $year=substr($date,0,4);
       $temp=$day.' '.$mymonth[$month-1].' '.$year;
       return $temp;
    }

    if(!empty($testimonials))
    {
        echo "<table cellpadding=0 cellspacing=0 style='border:none' class='mytable'>";
            echo "<tr> <th width=40px>ID</th>  <th width=80px>From</th>  <th width=240px>Name / Company Name</th>  <th width=120px>Date</th>  <th width=120px>Status</th>  <th width=200px>Action</th> </tr>";
            foreach($testimonials as $data)
            {
                echo "<td>".$data['testimonials']['id']."</td>";
                if(count($data['employers']))
                {
                    echo "<td> Employer </td>";
                    echo "<td> ".$data['employers']['company_name']." </td>";
                }
                else
                {
                    echo "<td> Jobseeker </td>";
                    echo "<td> ".$data['jobseekers']['salution']." ".$data['jobseekers']['first_name']." ".$data['jobseekers']['last_name']." </td>";
                }
                
                echo "<td>".mydate($data['testimonials']['created'])."</td>";
                echo "<td>";
                if($data['testimonials']['status']==1)
                { 
                    echo " Published "; 
                    echo " <br> ";
                    echo $ajax->link('[ Store ]',
                                        array('controller'=>'testimonials','action'=>'cancel_admin',$data['testimonials']['id']),
                                        array('update'=>'masterisi','class'=>'sky')
                                     );            

                }
                else
                { 
                    echo " Stored "; 
                    echo " <br> ";
                    echo $ajax->link('[ Publish ]',
                                        array('controller'=>'testimonials','action'=>'approve_admin',$data['testimonials']['id']),
                                        array('update'=>'masterisi','class'=>'sky')
                                     );            

                }
                echo "</td>";
                echo "<td>";
                echo $ajax->link('[ Edit ]',
                                    array('controller'=>'testimonials','action'=>'edit_admin',$data['testimonials']['id']),
                                    array('update'=>'slip','class'=>'sky','complete'=>"make_slip();")
                                 );            
                echo " &nbsp ";
                echo $ajax->link( '[ Delete ]', 
                        array('controller' => 'testimonials', 'action' => 'delete_admin',$data['testimonials']['id']),
                        array('update' => 'masterisi','class'=>'sky'),
                        "Are you sure ?"
                        );                           
                
                echo "</td>";
            echo "</tr>";
            }
            echo "<tr class='end'><td class='end' colspan=6> &nbsp </td></tr>";
        echo "</table>";            
    }
    else
    { echo "<span class='red'>Sorry, there is no data in this category</span>"; }
    echo "<div id='slip'></div>";  
?>